/*********************************************************************************
 *      Copyright:  (C) 2022 Li Yanting<liyanting2@163.com>
 *                  All rights reserved.
 *
 *       Filename:  get_ctx_conf.c
 *    Description:  This file 
 *                 
 *        Version:  1.0.0(06/23/2022)
 *         Author:  Li Yanting <liyanting2@163.com>
 *      ChangeLog:  1, Release initial version on "06/23/2022 16:40:50"
 *                 
 ********************************************************************************/

#ifndef _GET_CTX_CONF_H_
#define _GET_CTX_CONF_H_

#include <stdio.h>
#include "iniparser.h"
#include "logger.h"

#define BUFFER_SIZE 512

enum
{
    PUB,
    SUB
};

typedef struct mqtt_ctx_s
{
    char   host[BUFFER_SIZE];
    int    port;
    char   clientid[BUFFER_SIZE];
    char   username[BUFFER_SIZE];
    char   passwd[BUFFER_SIZE];
    char   pub_topic[BUFFER_SIZE];
    char   reply_topic[BUFFER_SIZE];
    int    alivetime;
    int    Qos;

    char   type[BUFFER_SIZE];
    char   clientToken[BUFFER_SIZE];

    char   service_id[BUFFER_SIZE];
    int    version;
} mqtt_ctx_t;


typedef struct collect_ctx_s
{
    char       time[32];
    float      temper;
} collect_ctx_t;

typedef struct iotd_ctx_s
{
    struct mosquitto     *mosq;
    mqtt_ctx_t           st_mqtt;
    collect_ctx_t        st_collect;
} iotd_ctx_t;


/*********************************************************************************
 *      Function name:  get_ctx_conf
 *        Description:  Get profile parameters
 *         @parameter:  ini_path  ini path
 *         @parameter:  st_iotd  Structure receiving configuration information
 *       Return value:  On error, -1 is returned. On success, temper is returned.
 ********************************************************************************/
int get_ctx_conf(char *ini_path, iotd_ctx_t *st_iotd);

#endif

